package com.contact.util.util.validation;

import com.contact.util.StringUtils;

/**
 * A collection of utility methods for validating strings. Small, but growing.
 */

public final class StringPropertyValidator {

    private StringPropertyValidator() {
        //cannot be instantiated!
    }

    /**
     * Verifies that a string (such as a bean property) has a non-zero length. If the string is null or zero-length,
     * then an exceptions is thrown.
     * 
     * @param propertyValue
     * @param propertyName
     * @throws ValidationException
     */

    public static void validate(String propertyValue, String propertyName) throws ValidationException {
        if (StringUtils.isEmpty(propertyValue)) {
            String msg = String.format("Required property '%s' cannot be empty.", propertyName);
            throw new ValidationException(msg);
        }
    }

}
